package com.itheima.d5_map_traverse;

import java.util.*;

public class MapDemo4 {
    public static void main(String[] args) {
        //拿到80个学生的数据
        List<String> data = new ArrayList<>();
        String[] selects ={"A","B","C","D"};
        Random r =new Random();
        for (int i = 0; i <80 ; i++) {
            int index = r.nextInt(4);
            data.add(selects[index]);
        }
        System.out.println(data);

        //统计每个选项的人数
        Map<String,Integer> map = new HashMap<>();
        for (int i = 0; i < data.size(); i++) {
            if(map.containsKey(data.get(i))){
                map.put(data.get(i),map.get(data.get(i))+1);
            }else{
                map.put(data.get(i),1);
            }
        }
        System.out.println(map);
    }
}
